%% filter param
fD = 50;
fN = fD*sqrt(3);

eN = 0.2;
eD = 0.5;

Ts = 0.0001;

wN = 2*pi*fN;
wD = 2*pi*fD;

K = (wD^2)/(wN^2);

%% num den calculation
n1 = 2*eN*wN;
n2 = wN^2;

d1 = 2*eD*wD;
d2 = wD^2;

sys = K*tf([1 n1 n2], [1 d1 d2]);
[num, den] = c2dm(K*[1, n1, n2],[1, d1, d2], Ts, 'tustin');

%% print for use
fprintf('copy the following for filter\n');
fprintf('num = [ %2.6f, %2.6f, %2.6f ]\n', num(1), num(2), num(3));
fprintf('den = [ %2.6f, %2.6f, %2.6f ]\n', den(1), den(2), den(3));

%% check data
a2 = str2num(sprintf('%2.6f', num(1)));
a1 = str2num(sprintf('%2.6f', num(2)));
a0 = str2num(sprintf('%2.6f', num(3)));
b1 = str2num(sprintf('%2.6f', den(2)));
b0 = str2num(sprintf('%2.6f', den(3)));

sysz = tf([a2, a1, a0], [1, b1, b0], Ts)
bode(sysz)

hold on;
